package com.eden.tech.controller;

import com.eden.tech.config.RetryUtil;
import com.eden.tech.controller.base.BaseController;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.remoting.RemoteAccessException;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.web.bind.annotation.*;

import java.time.LocalTime;
import java.util.Date;

@CrossOrigin
@RestController
@RequestMapping("/send")
@Api(value = "/send", description = "学校")
@Slf4j
public class SendController extends BaseController {

    @ApiOperation(value = "获取学校列表", notes = "")
    @PostMapping(value = "/sendOne", produces = {"application/json;charset=utf-8"})
    @Retryable(value = { RemoteAccessException.class }, maxAttempts = 3, backoff = @Backoff(delay = 5000l, multiplier = 1))
    public Object sendOne(@RequestBody String sendMessage) {
        System.out.print("消息为：" + sendMessage);
        log.info(LocalTime.now()+" do something...");
        throw new RemoteAccessException("RPC调用异常");
//       return RetryUtil.setRetryTimes(3).retry(new SendController(),sendMessage);
    }
}
